'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 每日任务
 * @author sundbcn@gmail.com (sun debing)
 */

var _ = require('lodash');
var missionConf = require('../config/missionConf');
var genRewardService = require('./genRewardService');

/**
 * 奖励列表
 * @param  {[type]} daily_id [description]
 * @param  {[type]} lv       [description]
 * @return {[type]}          [description]
 */
exports.getRewardList = function (job_type, mission_id) {
    var mission_reward_all_conf = missionConf.getMissionRewardConf(job_type, mission_id);
    var task_list = [];
    _.some(mission_reward_all_conf, function (mission_reward_item) {
        if (mission_reward_item.mission_id == mission_id) {
            task_list.push(genRewardService.generateReward(mission_reward_item));
            return true;
        }
    });
    return task_list;
};

/**
 * 获取金币奖励
 * @param  {[type]} mission_id [description]
 * @return {[type]}            [description]
 */
exports.getGoldReward = function (mission_id) {
    var task_conf = missionConf.getMissionConf(mission_id);
    if (!task_conf) {
        return 0;
    }
    return task_conf.gold_raward;
};

/**
 * 获取经验奖励
 * @param  {[type]} mission_id [description]
 * @return {[type]}            [description]
 */
exports.getExpReward = function (mission_id) {
    var task_conf = missionConf.getMissionConf(mission_id);
    if (!task_conf) {
        return 0;
    }
    return task_conf.exp_raward;
};
